import base64
from typing import List

import shortuuid
from peewee import JOIN

from afast_core.core_libs.captcha.cilent import generate_captcha
from afast_core.core_tools.jwt_helper import SimpleAuth
from infirmary_admin_src.infirmary_common.infirmary_controller import IAsyncSessionBaseController, IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends
from afast_core.core_tools import json_helper
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase


class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''
    pageNum: int = 1
    pageSize: int = 6
    searchCount: bool = False


class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 schema_param: XParam,
                 ):
        super().__init__(request=request)
        # 入参参数
        # 入参参数
        self.schema_param = schema_param


@RestControllerWithDepends()
class ChangeLogQueryPageController(IController):

    def business_login(self):
        pass

        return {
            "pageNum": 1,
            "pageSize": 6,
            "total": 6,
            "pages": 1,
            "list": [{
                "noticeId": 54,
                "title": "JetBrains Fleet 公测，下一代 IDE",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:36:10",
                "author": "开云",
                "source": "CSDN",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:36:10",
                "updateTime": "2022-10-22 14:36:10",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }, {
                "noticeId": 53,
                "title": "TypeScript 诞生 10 周年",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:34:56",
                "author": "开云",
                "source": "开源中国",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:34:56",
                "updateTime": "2022-10-22 14:34:56",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }, {
                "noticeId": 52,
                "title": "Windows Terminal 正式成为 Windows 11 默认终端",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:33:03",
                "author": "善逸",
                "source": "开源中国",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:33:03",
                "updateTime": "2022-10-22 14:33:03",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }, {
                "noticeId": 51,
                "title": "Spring Framework 6.0.0 RC2 发布",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:30:46",
                "author": "罗伊",
                "source": "CSDN",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:30:45",
                "updateTime": "2022-10-22 14:30:45",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }, {
                "noticeId": 50,
                "title": "Oracle 推出 JDK 8 的直接替代品",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:29:56",
                "author": "卓大",
                "source": "OSChina",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:29:56",
                "updateTime": "2022-10-22 14:29:56",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }, {
                "noticeId": 49,
                "title": "Spring Boot 3.0.0 首个 RC 发布",
                "noticeTypeId": 1,
                "noticeTypeName": "公告",
                "allVisibleFlag": True,
                "scheduledPublishFlag": False,
                "publishFlag": None,
                "publishTime": "2022-10-22 14:27:34",
                "author": "卓大",
                "source": "开源中国",
                "documentNumber": None,
                "pageViewCount": 0,
                "userViewCount": 0,
                "deletedFlag": False,
                "createUserName": None,
                "createTime": "2022-10-22 14:27:33",
                "updateTime": "2022-10-22 14:27:33",
                "viewFlag": True,
                "publishDate": "2022-10-22"
            }],
            "emptyFlag": False
        }
